package org.teamh.connection.handler;

import org.teamh.game.Start;
import org.teamh.gui.Event;

public class LoginHandler extends MasterHandler {

	public LoginHandler(Start start) {
		super(start);
	}
	
	public boolean handleMsg(String line) {
		 if (line.contains("ROLE")&&line.contains("EMAIL")) {
			String[] str = line.split(" ");
			start.getModel().setPlayerName(str[1].substring(5));
			start.getGui().addEvent(new Event("login", "true"));
			return true;
		 } else  if (line.startsWith("TEAM")) {
			String[] str = line.split(" ");
			start.getModel().setTeam(str[1].substring(5));	
			return true;
		} else if (line.contains("unknown user")){
			start.getGui().addEvent(new Event("login", "false"));
			return true;
		} else {
			return false;
		}
	}

	
}
